<template>
  <div>
    <dynamic-crud
      title="现金事务"
      :data="list"
      :option="option"
      :tableLoading="tableLoading"
      :disabled="isRecords"
    ></dynamic-crud>
    <div class="bottom-menu" v-if="isRecords">
      <el-button type="primary" @click="handleCancle" :loading="isSubmit"
        >取 消</el-button
      >
    </div>
  </div>
</template>

<script>
import { queryPastRecords } from "@/api/subwaystm/swstinputpassengerwork/cash-work";
export default {
  name: "cash-work-records",
  inject: ["passengerWork"],
  data() {
    return {
      list: [],
      isSubmit: false,
      tableLoading: false,
      option: {
        column: [
          {
            label: "事件详情",
            prop: "eventDetail",
            type: "select",
            dicUrl: "/admin/dict/type/cash_work_event_detail",
            cell: true,
            filterable: true,
            allowCreate: true,
          },
          {
            label: "处理结果",
            prop: "handleResult",
            cell: true,
          },{
                label: "金额",
		prop: "amount",
		type: "number",
		precision: 2,
		cell: true,
		step: 0,
            },{
            label: "备注",
            prop: "remark",
            type: "input",
            cell: true,
          },
          {
            label: "事务发生时间",
            prop: "workTime",
            type: "datetime",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            cell: true,
            width: 205,
          },{
            label: 'POS交易类型',
            prop: 'posType',
            type: 'select',
            dicUrl: '/admin/dict/type/cash_work_pos_type',
            cell: true,
            filterable: true,
            allowCreate: false,
            width: 110
          },{
	      label: '票种',
	      prop: 'ticketType',
	      type: 'select',
	      cell: true,
	      cascaderItem: ["ticketSubType"],
	      dicUrl: '/support/swpmticketcardtype/dict/ticketPosCash',
	      props: {
		label: 'mainName',
		value: 'mainEnName'
	      },
              width: 120
	   },{
	      label: '车票名称',
	      prop: 'ticketSubType',
	      type: 'select',
	      dicUrl: '/support/swpmticketcardtypeparam/dictAll/{{key}}',
	      props: {
		label: 'subName',
		value: 'subEnName'
	      },
             cell: true,
	      // component: 'ticket-name-select',
	      width: 130
	    },{
	      label: '数量',
	      prop: 'posSum',
	      type: 'number',
	      cell: true,
	      step:0,
	      width: 110
            },{
	      "type": "select",
	      "label": "POS卡类型",
	      "prop": "posCardType",
	       dicUrl:'/admin/dict/type/pos_card_type' ,
	       width: 180,
	       cell:true
	    }
        ],
      },
    };
  },
  computed: {
    isRecords() {
      return this.boxType == "records";
    },
  },
  props: {
    workInfoRecords: Object,
    boxType: String,
  },
  methods: {
    getList() {
      this.list = [];
      this.tableLoading = true;
      let param = {};
      param.id = this.workInfoRecords.id;
      if(!this.validatenull(this.workInfoRecords.id)){
        queryPastRecords(param)
          .then((response) => {
            //console.log("------------->"+response)
            this.list = response.data.data;
            this.tableLoading = false;
          })
          .catch(() => {
            this.tableLoading = false;
            this.$message.error("查询失败");
          });
      }else{
          this.tableLoading = false;
      }
    },
    clear() {
      this.list = [];
    },
    handleCancle() {
      this.passengerWork.closeDialogPastRecords();
    },
  },
};
</script>

<style lang="scss" scoped>
.bottom-menu {
  margin-top: 30px;
  display: flex;
  justify-content: center;
}
</style>
